package pool;

import java.util.Random;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GroupTask implements Runnable {
	
    private static final Logger LOG = LoggerFactory.getLogger(GroupTask.class);
	
	private String groupId;
	
	private String messageId;

	public GroupTask(String groupId, String messageId){
		this.groupId = groupId;
		this.messageId = messageId;
	}
	
	@Override
	public void run() {	
		try {
			Random r = new Random();
			int sleepTime = r.nextInt(500);
			
//			int sleepTime = 1000 - (Integer.parseInt(messageId) * 10);
			
			Thread.sleep(sleepTime);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		LOG.info(this.toString());
	}

	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	public String getMessageId() {
		return messageId;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}

	@Override
	public String toString() {
		return "GroupTask [groupId=" + groupId + ", messageId=" + messageId + "]";
	}

}
